param( [string]$modelname )
while ($true) {
    $modelExists = ollama list | Select-String $modelname
    if ($modelExists) {
        Write-Host "model is ready"
        break
    }


    Write-Host "download..."
    $process = Start-Process -FilePath "ollama" -ArgumentList "pull", $modelname -PassThru -NoNewWindow

    Start-Sleep -Seconds 60

    try {
        Stop-Process -Id $process.Id -Force -ErrorAction Stop
        Write-Host "kill and restart..."
    }
    catch {
        Write-Host "error"
    }
}
